home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 5 Developer's Kit / vb5 dev kit.iso / dev / csview / fchart.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-04-05  |  7.9 KB  |  262 lines

  1. VERSION 2.00
  2. Begin Form fchart 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "Charting"
  5.    ClientHeight    =   5670
  6.    ClientLeft      =   1095
  7.    ClientTop       =   1020
  8.    ClientWidth     =   8190
  9.    Height          =   6075
  10.    Left            =   1035
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   5670
  13.    ScaleWidth      =   8190
  14.    Top             =   675
  15.    Width           =   8310
  16.    Begin ComboBox Combo1 
  17.       FontBold        =   0   'False
  18.       FontItalic      =   0   'False
  19.       FontName        =   "MS Sans Serif"
  20.       FontSize        =   8.25
  21.       FontStrikethru  =   0   'False
  22.       FontUnderline   =   0   'False
  23.       Height          =   315
  24.       Left            =   1320
  25.       Style           =   2  'Dropdown List
  26.       TabIndex        =   3
  27.       Top             =   285
  28.       Width           =   1605
  29.    End
  30.    Begin CommandButton Command2 
  31.       BackColor       =   &H00C0C0C0&
  32.       Caption         =   "Zoom-"
  33.       FontBold        =   0   'False
  34.       FontItalic      =   0   'False
  35.       FontName        =   "MS Sans Serif"
  36.       FontSize        =   8.25
  37.       FontStrikethru  =   0   'False
  38.       FontUnderline   =   0   'False
  39.       Height          =   375
  40.       Index           =   1
  41.       Left            =   6765
  42.       TabIndex        =   2
  43.       Top             =   135
  44.       Width           =   1200
  45.    End
  46.    Begin CommandButton Command2 
  47.       BackColor       =   &H00C0C0C0&
  48.       Caption         =   "Zoom+"
  49.       FontBold        =   0   'False
  50.       FontItalic      =   0   'False
  51.       FontName        =   "MS Sans Serif"
  52.       FontSize        =   8.25
  53.       FontStrikethru  =   0   'False
  54.       FontUnderline   =   0   'False
  55.       Height          =   375
  56.       Index           =   0
  57.       Left            =   5535
  58.       TabIndex        =   1
  59.       Top             =   135
  60.       Width           =   1200
  61.    End
  62.    Begin CommandButton Command1 
  63.       BackColor       =   &H00C0C0C0&
  64.       Caption         =   "Print"
  65.       FontBold        =   0   'False
  66.       FontItalic      =   0   'False
  67.       FontName        =   "MS Sans Serif"
  68.       FontSize        =   8.25
  69.       FontStrikethru  =   0   'False
  70.       FontUnderline   =   0   'False
  71.       Height          =   375
  72.       Left            =   4320
  73.       TabIndex        =   0
  74.       Top             =   135
  75.       Width           =   1200
  76.    End
  77.    Begin vsViewPort vsViewPort1 
  78.       BackColor       =   &H00C0C0C0&
  79.       ConvInfo        =   FCHART.FRX:0000
  80.       Height          =   4650
  81.       Left            =   255
  82.       Top             =   690
  83.       VirtualHeight   =   0
  84.       VirtualWidth    =   0
  85.       Width           =   7305
  86.       Begin vsPrinter vsPrinter1 
  87.          BrushColor      =   &H00C0C0C0&
  88.          ConvInfo        =   FCHART.FRX:000B
  89.          FontName        =   "Times New Roman"
  90.          FontSize        =   11
  91.          HdrFontBold     =   -1  'True
  92.          HdrFontName     =   "Courier New"
  93.          HdrFontSize     =   14
  94.          Height          =   2535
  95.          Left            =   285
  96.          PageBorder      =   0  'None
  97.          TableSep        =   "|;"
  98.          Top             =   225
  99.          Width           =   1530
  100.       End
  101.    End
  102.    Begin Label Label1 
  103.       BackStyle       =   0  'Transparent
  104.       Caption         =   "Borders"
  105.       FontBold        =   0   'False
  106.       FontItalic      =   0   'False
  107.       FontName        =   "MS Sans Serif"
  108.       FontSize        =   8.25
  109.       FontStrikethru  =   0   'False
  110.       FontUnderline   =   0   'False
  111.       Height          =   270
  112.       Left            =   540
  113.       TabIndex        =   4
  114.       Top             =   330
  115.       Width           =   750
  116.    End
  117.    Begin Image Image1 
  118.       Height          =   555
  119.       Index           =   1
  120.       Left            =   3315
  121.       Picture         =   FCHART.FRX:0016
  122.       Stretch         =   -1  'True
  123.       Top             =   135
  124.       Visible         =   0   'False
  125.       Width           =   1020
  126.    End
  127.    Begin Image Image1 
  128.       Height          =   600
  129.       Index           =   0
  130.       Left            =   3030
  131.       Picture         =   FCHART.FRX:625E
  132.       Stretch         =   -1  'True
  133.       Top             =   30
  134.       Visible         =   0   'False
  135.       Width           =   780
  136.    End
  137. Option Explicit
  138. Dim strArr(7, 3) As String
  139. Dim zoom%
  140. Dim xd, yd
  141. Function BoxText (row%, col%) As String
  142.     If strArr(row, col) = "" Then
  143.         BoxText = "VideoSoft" & Chr(13) & "VSView Controls"
  144.     Else
  145.         BoxText = strArr(row, col)
  146.     End If
  147. End Function
  148. Function BoxX (row%, col%, w!) As Single
  149.     BoxX = vsPrinter1.MarginLeft + 500 + col * w * 1.2
  150. End Function
  151. Function BoxY (row%, col%, h!) As Single
  152.     Dim y!
  153.     y = 1 / (2 ^ col) * (row + .5) * 8 * h * 1.2
  154.     BoxY = vsPrinter1.MarginTop + y
  155. End Function
  156. Sub Combo1_Click ()
  157.     DoChart
  158. End Sub
  159. Sub Command1_Click ()
  160.     vsPrinter1.Preview = False
  161.     DoChart
  162.     vsPrinter1.Preview = True
  163. End Sub
  164. Sub Command2_Click (Index As Integer)
  165.     If Index = 0 Then
  166.         zoom = zoom + 20
  167.     Else
  168.         zoom = zoom - 20
  169.     End If
  170.     If zoom < 20 Then zoom = 20
  171.     If zoom > 120 Then zoom = 120
  172.     SetZoom zoom
  173. End Sub
  174. Sub DoChart ()
  175.     vsPrinter1.Action = 3
  176.     DoDrawBorders
  177.     vsPrinter1.FontSize = 36
  178.     vsPrinter1 = "VideoSoft Flowchart"
  179.     vsPrinter1.FontSize = 11
  180.     DoDrawBoxes
  181.     vsPrinter1.Action = 6
  182. End Sub
  183. Sub DoDrawBorders ()
  184.     vsPrinter1.X1 = 0
  185.     vsPrinter1.Y1 = 0
  186.     vsPrinter1.X2 = vsPrinter1.PageWidth
  187.     vsPrinter1.Y2 = vsPrinter1.PageHeight
  188.     vsPrinter1.Picture = image1(combo1.ListIndex).Picture
  189. End Sub
  190. Sub DoDrawBoxes ()
  191.     Dim row%, col%
  192.     Dim x!, y!, w!, h!, s$, sl$
  193.     ' initialize
  194.     w = 1800
  195.     h = w / 2
  196.     ' draw a bunch of boxes
  197.     For col = 0 To 3
  198.         For row = 0 To 2 ^ col - 1
  199.             
  200.             ' draw the box
  201.             x = BoxX(row, col, w)
  202.             y = BoxY(row, col, h)
  203.             s = BoxText(row, col)
  204.             TextBox x, y, w, h, s
  205.             ' draw connecting lines
  206.             If col < 3 Then
  207.                 vsPrinter1.X1 = x + w
  208.                 vsPrinter1.Y1 = y + h / 2
  209.                 vsPrinter1.X2 = x + w * 1.1
  210.                 vsPrinter1.Y2 = y + h / 2
  211.                 vsPrinter1.Draw = 1 ' line
  212.                 x = BoxX(row, col + 1, w)
  213.                 y = BoxY(2 * row, col + 1, h) + h / 2
  214.                 sl = Str(x) + Str(y) + Str(x - .1 * w) + Str(y)
  215.                 y = BoxY(2 * row + 1, col + 1, h) + h / 2
  216.                 sl = sl + Str(x - .1 * w) + Str(y) + Str(x) + Str(y)
  217.                 vsPrinter1.PolyLine = sl
  218.             End If
  219.         Next
  220.     Next
  221. End Sub
  222. Sub Form_Load ()
  223.     ' initialize
  224.     vsPrinter1.Preview = True
  225.     zoom = 50
  226.     SetZoom zoom
  227.     combo1.AddItem "Feet"
  228.     combo1.AddItem "Checkers"
  229.     combo1.ListIndex = 1
  230.     ' do the drawing
  231.     DoChart
  232. End Sub
  233. Sub SetZoom (ByVal z!)
  234.     vsPrinter1.Width = vsPrinter1.PageWidth * z / 100
  235.     vsPrinter1.Height = vsPrinter1.PageHeight * z / 100
  236.     vsviewport1.VirtualWidth = vsPrinter1.Width + 2 * vsPrinter1.Left
  237.     vsviewport1.VirtualHeight = vsPrinter1.Height + 2 * vsPrinter1.Top
  238. End Sub
  239. Sub TextBox (x!, y!, w!, h!, s$)
  240.     Dim ml&, mr&
  241.     ' draw the box
  242.     vsPrinter1.X1 = x
  243.     vsPrinter1.Y1 = y
  244.     vsPrinter1.X2 = x + w
  245.     vsPrinter1.Y2 = y + h
  246.     vsPrinter1.Draw = 2 ' rectangle
  247.     ' draw the text
  248.     ml = vsPrinter1.MarginLeft
  249.     mr = vsPrinter1.MarginRight
  250.     vsPrinter1.MarginLeft = x + 25
  251.     vsPrinter1.MarginRight = vsPrinter1.PageWidth - x - w - 25
  252.     vsPrinter1.CurrentX = vsPrinter1.MarginLeft
  253.     vsPrinter1.CurrentY = y + 25
  254.     vsPrinter1 = s
  255.     vsPrinter1.MarginLeft = ml
  256.     vsPrinter1.MarginRight = mr
  257. End Sub
  258. Sub vsPrinter1_MouseDown (Button As Integer, Shift As Integer, x As Single, y As Single)
  259.     xd = x
  260.     yd = y
  261. End Sub
  262.